﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace WFL.Office.Word
{
    public class TableColumns
    {

        public TableColumn this[int index]
        {
            get { return new TableColumn(_columns[index]) { Table = Table }; }
        }

        public int Count
        {
            get { return _columns.Count; }
        }

        public float Width
        {
            get { return _columns.Width; }
            set { _columns.Width = value; }
        }

        private Columns _columns;

        public WordTable Table
        {
            get;
            internal set;
        }

        internal TableColumns(Columns columns)
        {
            _columns = columns;
        }

        public TableColumn Add(TableColumn beforeColumn = null)
        {
            object beforeColumnArg = beforeColumn != null ? beforeColumn._column : Type.Missing;
            return new TableColumn(_columns.Add(ref beforeColumnArg)) { Table = Table };
        }

        public void SetWidth(float columnWidth, RulerStyle rulerStyle)
        {
            _columns.SetWidth(columnWidth, (WdRulerStyle)rulerStyle);
        }
    }
}
